<template>
  <div class="container">
    <Breadcrumb :items="['数据上报', '数据上报']" />
    <a-card class="general-card" style="padding-top:0px">
      <a-row>
        <a-col :flex="1">
          <a-form :model="formModel" label-align="right">
            <a-row :gutter="16">
              <a-space wrap :size="5">
                <a-form-item field="quarter" label-col-flex="70px" label="问题类别">
                  <a-select v-model="formModel.bigTypeNameList.value" :style="{ width: '240px' }" allow-clear
                    placeholder="全部" allow-search multiple :trigger-props="{ autoFitPopupMinWidth: true }">
                    <a-option :value="item.label" v-for="item in questionList1">{{ item.label }}</a-option>
                  </a-select>
                </a-form-item>
                <a-form-item field="userName" label-col-flex="120px" label="清单查摆问题表现">
                  <a-select v-model="formModel.prominentProblemList.value" :style="{ width: '240px' }" allow-clear
                    placeholder="全部" multiple :trigger-props="{ autoFitPopupMinWidth: true }">
                    <a-option :value="item.label" v-for="item in questionList">{{ item.label }}</a-option>
                  </a-select>
                </a-form-item>
                <a-form-item field="quarter" label-col-flex="100px" label="突出问题类型">
                  <a-select v-model="formModel.problemTypeList.value" :style="{ width: '160px' }" allow-clear
                    placeholder="全部" allow-search multiple :trigger-props="{ autoFitPopupMinWidth: true }">
                    <a-option :value="item.label" v-for="item in questionList2">{{ item.label }}</a-option>
                  </a-select>
                </a-form-item>

                <a-form-item field="department" label-col-flex="70px" label="责任单位">
                  <a-select v-model="formModel.department.value" placeholder="请输入责任单位" :style="{ width: '160px' }"
                    allow-clear allow-search>
                    <a-option v-for="item in departmentList" :key="item.id" :value="item.department">{{ item.department
                      }}</a-option>
                  </a-select>
                </a-form-item>

                <a-form-item field="quarter" label-col-flex="70px" label="创建日期">
                  <a-range-picker v-model="formModel.dateRange.value" mode="date" style="width: 240px;" />
                </a-form-item>

                <a-form-item field="quarter" label-col-flex="70px" label="完成时限">
                  <a-range-picker v-model="formModel.dateRange2.value" mode="date" style="width: 240px;" />
                </a-form-item>

                <a-form-item label-col-flex="0px" label="">
                  <a-space direction="horizontal" :size="12">
                    <a-button status="success" @click="fetchData">
                      <template #icon>
                        <icon-search />
                      </template>
                      查询
                    </a-button>
                    <a-button type="primary" status="warning" @click="addDataShowFun">
                      <template #icon>
                        <icon-plus />
                      </template>
                      新建
                    </a-button>
                    <a-button @click="leadAddShow">
                      <template #icon>
                        <icon-upload />
                      </template>
                      批量导入
                    </a-button>
                  </a-space>
                </a-form-item>
              </a-space>
            </a-row>
          </a-form>
        </a-col>
      </a-row>
      <a-table :data="renderData" :columns="columns" :pagination="true" :scrollbar="true"
        :scroll="{ x: '3200px', y: '80vh' }" :bordered="{ cell: true }" :body-cell-style="bodyCellClass"
        :summary-span-method="spanMethod" :summary="summary">
        <template #summary-cell="{ column, record, rowIndex }">
          <span>{{ record[column.dataIndex] }}</span>
        </template>
        <!-- rectification -->
        <!-- remark -->
        <template #remark="{ rowIndex, record }">
          <a-tooltip :content="record.remark" position="top" mini style="display: flex;
              height: 70px;
              align-items: center;">
            <span style="
                text-align: left;
                width: 220px;
                height: 70px;
                display: block;
                -webkit-line-clamp: 3;
                overflow: hidden;">{{ record.remark }}</span>
          </a-tooltip>
        </template>
        <template #rectification="{ rowIndex, record }">
          <a-tooltip :content="record.rectificationMeasures" position="top" mini style="display: flex;
              height: 70px;
              align-items: center;">
            <span style="
                text-align: left;
                width: 220px;
                height: 70px;
                display: block;
                -webkit-line-clamp: 3;
                overflow: hidden;">{{ record.rectificationMeasures }}</span>
          </a-tooltip>
        </template>
        <template #circular="{ rowIndex }">
          <div style="width: 156px;margin-left:-15px;height:25px;line-height:25px;"
            v-for="item, index in renderData[rowIndex].circularIssuesList"
            :style="{ borderBottom: index === renderData[rowIndex].circularIssuesList.length - 1 ? 'none' : '1px solid #cccccc' }"
            :key="index">
            <a-tooltip :content="item.no" position="top" mini>
              <span
                style="overflow: hidden;text-overflow: ellipsis;display: block;width: 160px;height: 30px;">{{ item.no }}</span>
            </a-tooltip>
          </div>
        </template>
        <template #circularnum="{ rowIndex }">
          <div style="width: 112px;margin-left:-15px;height:25px;line-height:25px;"
            v-for="item, index in renderData[rowIndex].circularIssuesList"
            :style="{ borderBottom: index === renderData[rowIndex].circularIssuesList.length - 1 ? 'none' : '1px solid #cccccc' }"
            :key="index">
            <span>{{ item.value }}</span>
          </div>
        </template>
        <template #established="{ rowIndex }">
          <div>
            <div v-for="item, index in renderData[rowIndex].establishedNameList"
              style="width: 110%;margin-left:-15px;height:30px;line-height:25px;" :style="{
                borderBottom: index === renderData[rowIndex].establishedNameList.length - 1 ? 'none' : '1px solid #cccccc',
                marginTop: index === 0 ? '0px' : '8px'
              }" :key="index">
              <a-tooltip :content="item.name" position="top" mini>
                <span
                  style="overflow: hidden;text-overflow: ellipsis;display: block;width: 100%;height: 30px;line-height:25px;">{{ item.name }}</span>
              </a-tooltip>
            </div>
          </div>
        </template>
        <template #action="{ rowIndex }">
          <a-button type="outline" status="success" shape="round" size="mini" @click="editItem(renderData[rowIndex])"
            style="margin-bottom: 3px;">
            <template #default>更新</template>
          </a-button>
          <a-button type="outline" status="danger" shape="round" size="mini" @click="deleteItem(renderData[rowIndex])">
            <template #default>删除</template>
          </a-button>
        </template>
      </a-table>

    </a-card>

    <!-- 侧边修改数据 -->
    <a-drawer :width="1080" :visible="editvisible" @before-ok="handleEditOk" @cancel="handleEditCancel" unmountOnClose>
      <template #title>
        修改数据
      </template>
      <div>
        <a-form :model="editDataForm" layout="vertical" label-align="right">
          <a-row>
            <p>基本数据</p>
            <a-col :span="24">
              <a-form-item field="bigTypeName" label-col-flex="120px" label="问题类别" required>
                <!-- <a-select v-model="addDataForm.bigTypeName.value" :style="{width:'300px'}" placeholder="请选择问题类别">
                    <a-option :value="item.label" v-for="item in questionList1">{{item.label}}</a-option>
                  </a-select> -->
                <a-checkbox-group v-model="editDataForm.bigTypeNameList.value" @change="changeEditCheckGroup"
                  :options="questionList1" />
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item field="prominentProblem" label-col-flex="120px" label="清单查摆问题表现" required>
                <a-cascader v-model="editDataForm.prominentProblem.value" :format-label="format" allow-search
                  allow-clear readonly :options="questionList" :field-names="fieldNames" :style="{ width: '300px' }"
                  placeholder="请选择清单查摆问题表现" />
              </a-form-item>
            </a-col>

            <a-col :span="8">
              <a-form-item field="problemType" label-col-flex="120px" label="突出问题类型" required>
                <a-input v-model="editDataForm.problemType.value" readonly :style="{ width: '300px' }" />
              </a-form-item>
            </a-col>
            <a-col :span="8"></a-col>
            <a-col :span="8">
              <a-form-item field="rectificationMeasures" label-col-flex="120px" label="整改措施" required>
                <a-textarea v-model="editDataForm.rectificationMeasures.value" readonly :style="{ width: '300px' }" />
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item field="completionDeadline" label-col-flex="120px" label="完成时限" required>
                <a-date-picker v-model="editDataForm.completionDeadline.value" readonly :style="{ width: '300px' }"
                  :disabledDate="(current: any) => (current < dayjs().add(-1, 'day'))" />
              </a-form-item>
            </a-col>
            <a-col :span="8"></a-col>
            <!-- <a-col :span="12">
              <a-form-item field="department" label-col-flex="120px" label="部门名称" required>
                <a-input v-model="editDataForm.department.value" readonly :style="{ width: '300px' }" />
              </a-form-item>
            </a-col> -->
            <a-col :span="8">
              <a-form-item field="responsibleLeader" label-col-flex="120px" label="牵头领导" required>
                <a-input v-model="editDataForm.responsibleLeader.value" readonly placeholder="请输入牵头领导"
                  :style="{ width: '300px' }" />
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item field="supervisingLeader" label-col-flex="120px" label="分管领导" required>
                <a-input v-model="editDataForm.supervisingLeader.value" readonly placeholder=""
                  :style="{ width: '300px' }" />
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item field="department" label-col-flex="120px" label="部门名称" required>
                <a-input v-model="editDataForm.department.value" readonly :style="{ width: '300px' }" />
              </a-form-item>
            </a-col>
            <a-col :span="24">
              <p>进展成效</p>
            </a-col>
            <!-- 自查自纠发现问题数	已销号	整治处理中 -->
            <a-col :span="8">
              <a-form-item field="problemsFoundCount" label-col-flex="120px" label="自查自纠发现问题数" required>
                <a-input-number v-model="editDataForm.problemsFoundCount.value" :precision="0"
                  :style="{ width: '300px' }" />
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item field="closedCount" label-col-flex="120px" label="已整改销号数" required>
                <a-input-number v-model="editDataForm.closedCount.value" @change="changeEditInProgressCount"
                  :precision="0" :style="{ width: '300px' }" />
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item field="inProgressCount" label-col-flex="120px" label="整治处理中数" required>
                <a-input-number v-model="editDataForm.inProgressCount.value" :precision="0"
                  :style="{ width: '300px' }" />
              </a-form-item>
            </a-col>

            <!-- //查处违纪违法案件数	组织处理人数	纪律处分人数 -->

            <a-col :span="8" v-if="editDataForm.bigTypeName.value.indexOf('存量化解类') > -1 ||
              editDataForm.bigTypeName.value.indexOf('其他类') > -1 ||
              editDataForm.bigTypeName.value.indexOf('新增问题类') > -1">
              <a-form-item field="disciplinaryCases" label-col-flex="120px" label="查处违纪违法案件数" required>
                <a-input-number v-model="editDataForm.disciplinaryCases.value" :precision="0"
                  :style="{ width: '300px' }" />
              </a-form-item>
            </a-col>
            <a-col :span="8" v-if="editDataForm.bigTypeName.value.indexOf('存量化解类') > -1 ||
              editDataForm.bigTypeName.value.indexOf('其他类') > -1 ||
              editDataForm.bigTypeName.value.indexOf('新增问题类') > -1">
              <a-form-item field="punishedPersons" label-col-flex="120px" label="组织处理人数" required>
                <a-input-number v-model="editDataForm.punishedPersons.value" :precision="0"
                  :style="{ width: '300px' }" />
              </a-form-item>
            </a-col>
            <a-col :span="8" v-if="editDataForm.bigTypeName.value.indexOf('存量化解类') > -1 ||
              editDataForm.bigTypeName.value.indexOf('其他类') > -1 ||
              editDataForm.bigTypeName.value.indexOf('新增问题类') > -1">
              <a-form-item field="disciplinaryPunishedPersons" label-col-flex="120px" label="纪律处分人数" required>
                <a-input-number v-model="editDataForm.disciplinaryPunishedPersons.value" :precision="0"
                  :style="{ width: '300px' }" />
              </a-form-item>
            </a-col>

            <a-col :span="8" v-if="editDataForm.bigTypeName.value.indexOf('存量化解类') > -1 ||
              editDataForm.bigTypeName.value.indexOf('其他类') > -1 ||
              editDataForm.bigTypeName.value.indexOf('新增问题类') > -1">
              <a-form-item field="recommendationLetters" label-col-flex="120px" label="发出执纪执法建议（文书）数" required>
                <a-input-number v-model="editDataForm.recommendationLetters.value" :precision="0"
                  :style="{ width: '300px' }" />
              </a-form-item>
            </a-col>
          </a-row>
          
          <a-row v-if="editDataForm.bigTypeName.value.indexOf('存量化解类') > -1 ||
            editDataForm.bigTypeName.value.indexOf('其他类') > -1 ||
            editDataForm.bigTypeName.value.indexOf('新增问题类') > -1"
            v-for="(item, index) in editDataForm.circularIssuesList.value" :key="item.id">
            <a-col :span="8">
              <a-form-item field="circularNo" label-col-flex="120px" label="印发通报编号" required>
                <a-input v-model="item.no" :style="{ width: '300px' }" />
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item field="circularIssues" label-col-flex="120px" label="通报涉及本单位问题数" required>
                <a-input-number v-model="item.value" :precision="0" :style="{ width: '300px' }" />
              </a-form-item>
            </a-col>
            <a-col :span="3">
              <a-button style="margin-top: 35px;" @click="addCircularItem" size="mini">+</a-button>
              <a-button style="margin-top: 35px;margin-left:5px" @click="removeCircularItem(index)"
                size="mini">-</a-button>
            </a-col>
          </a-row>
          <a-row>
            <!-- //建立制度数 -->
            <a-col :span="8" v-if="editDataForm.bigTypeName.value.indexOf('建章立制类') > -1 ||
              editDataForm.bigTypeName.value.indexOf('试点类') > -1 ||
              editDataForm.bigTypeName.value.indexOf('其他类') > -1 ||
              editDataForm.bigTypeName.value.indexOf('新增问题类') > -1">
              <a-form-item field="establishedSystems" label-col-flex="120px" label="建立制度个数" required>
                <a-input-number v-model="editDataForm.establishedSystems.value" :precision="0"
                  :style="{ width: '300px' }" @change="changeEstablishedSystems" />
              </a-form-item>
            </a-col>
            <a-col :span="8" v-if="editDataForm.bigTypeName.value.indexOf('建章立制类') > -1 ||
              editDataForm.bigTypeName.value.indexOf('试点类') > -1 ||
              editDataForm.bigTypeName.value.indexOf('其他类') > -1 ||
              editDataForm.bigTypeName.value.indexOf('新增问题类') > -1">
              <a-form-item field="establishedName" label-col-flex="120px" label="建立制度名称" required>
                <div>
                  <a-input v-for="(item, index) in editDataForm.establishedSystems.value" :key="index"
                    placeholder="请填写每个制度对应的名称" v-model="editDataForm.establishedNameList.value[index].name"
                    :style="{ width: '300px', marginTop: '5px' }" />
                </div>
              </a-form-item>
            </a-col>

            <a-col :span="24">
              <a-form-item field="remark" label-col-flex="120px" label="其他情况" required>
                <a-textarea v-model="editDataForm.remark.value" :style="{ width: '652px' }" />
              </a-form-item>
            </a-col>

          </a-row>
        </a-form>
      </div>
    </a-drawer>


    <a-drawer :width="1080" :visible="addvisible" @before-ok="preHandAddOk" @cancel="handleCancel" unmountOnClose>
      <template #title>
        <div style="display:flex;justify-content: space-between;width: 980px;">
          <p>新增数据</p>
          <p>{{ addDataForm.department.value }}</p>
        </div>
      </template>
      <div>
        <a-form :model="addDataForm" layout="vertical" label-align="right">
          <a-row>
            <p>基本数据</p>
            <a-col :span="24">
              <a-form-item field="bigTypeName" label-col-flex="120px" label="问题类别" required>
                <!-- <a-select v-model="addDataForm.bigTypeName.value" :style="{width:'300px'}" placeholder="请选择问题类别">
                    <a-option :value="item.label" v-for="item in questionList1">{{item.label}}</a-option>
                  </a-select> -->
                <a-checkbox-group v-model="addDataForm.bigTypeNameList.value" @change="changeCheckGroup"
                  :options="questionList1" />
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item field="prominentProblem" label-col-flex="120px" label="清单查摆问题表现" required>
                <a-cascader v-model="addDataForm.prominentProblem.value" :format-label="format" allow-search allow-clear
                  :options="questionList" :field-names="fieldNames" :style="{ width: '300px' }"
                  placeholder="请选择清单查摆问题表现" />
              </a-form-item>
            </a-col>

            <a-col :span="8">
              <a-form-item field="problemType" label-col-flex="120px" label="突出问题类型" required>
                <a-input v-model="addDataForm.problemType.value" readonly :style="{ width: '300px' }" />
              </a-form-item>
            </a-col>
            <a-col :span="8"></a-col>
            <a-col :span="8">
              <a-form-item field="rectificationMeasures" label-col-flex="120px" label="整改措施" required>
                <a-textarea v-model="addDataForm.rectificationMeasures.value" :style="{ width: '300px' }" />
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item field="completionDeadline" label-col-flex="120px" label="完成时限" required>
                <a-date-picker v-model="addDataForm.completionDeadline.value" :style="{ width: '300px' }"
                  :disabledDate="(current: any) => (current < dayjs().add(-1, 'day'))" />
              </a-form-item>
            </a-col>
            <a-col :span="8"></a-col>
            <!-- <a-col :span="12">
              <a-form-item field="department" label-col-flex="120px" label="责任单位" required>
                <a-input v-model="addDataForm.department.value" readonly :style="{ width: '300px' }" />
              </a-form-item>
            </a-col> -->
            <a-col :span="8">
              <a-form-item field="responsibleLeader" label-col-flex="120px" label="牵头领导" required>
                <a-input v-model="addDataForm.responsibleLeader.value" placeholder="请输入牵头领导"
                  :style="{ width: '300px' }" />
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item field="supervisingLeader" label-col-flex="120px" label="分管领导" required>
                <a-input v-model="addDataForm.supervisingLeader.value" placeholder="请输入分管领导"
                  :style="{ width: '300px' }" />
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item field="department" label-col-flex="120px" label="部门名称" required>
                <a-select v-model="addDataForm.department.value" placeholder="请选择部门" allow-search
                  :style="{ width: '300px' }">
                  <a-option v-for="item in departmentList" :key="item.id" :value="item.department">{{ item.department
                    }}</a-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :span="24">
              <p>进展成效</p>
            </a-col>
            <!-- 自查自纠发现问题数	已销号	整治处理中 -->
            <a-col :span="8">
              <a-form-item field="problemsFoundCount" label-col-flex="120px" label="自查自纠发现问题数" required>
                <a-input-number v-model="addDataForm.problemsFoundCount.value" :precision="0"
                  :style="{ width: '300px' }" />
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item field="closedCount" label-col-flex="120px" label="已整改销号数" required>
                <a-input-number v-model="addDataForm.closedCount.value" @change="changeInProgressCount" :precision="0"
                  :style="{ width: '300px' }" />
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item field="inProgressCount" label-col-flex="120px" label="整治处理中数" required>
                <a-input-number v-model="addDataForm.inProgressCount.value" :precision="0"
                  :style="{ width: '300px' }" />
              </a-form-item>
            </a-col>

            <!-- //查处违纪违法案件数	组织处理人数	纪律处分人数 -->

            <a-col :span="8" v-if="addDataForm.bigTypeName.value.indexOf('存量化解类') > -1 ||
              addDataForm.bigTypeName.value.indexOf('其他类') > -1 ||
              addDataForm.bigTypeName.value.indexOf('新增问题类') > -1">
              <a-form-item field="disciplinaryCases" label-col-flex="120px" label="查处违纪违法案件数" required>
                <a-input-number v-model="addDataForm.disciplinaryCases.value" :precision="0"
                  :style="{ width: '300px' }" />
              </a-form-item>
            </a-col>
            <a-col :span="8" v-if="addDataForm.bigTypeName.value.indexOf('存量化解类') > -1 ||
              addDataForm.bigTypeName.value.indexOf('其他类') > -1 ||
              addDataForm.bigTypeName.value.indexOf('新增问题类') > -1">
              <a-form-item field="punishedPersons" label-col-flex="120px" label="组织处理人数" required>
                <a-input-number v-model="addDataForm.punishedPersons.value" :precision="0"
                  :style="{ width: '300px' }" />
              </a-form-item>
            </a-col>
            <a-col :span="8" v-if="addDataForm.bigTypeName.value.indexOf('存量化解类') > -1 ||
              addDataForm.bigTypeName.value.indexOf('其他类') > -1 ||
              addDataForm.bigTypeName.value.indexOf('新增问题类') > -1">
              <a-form-item field="disciplinaryPunishedPersons" label-col-flex="120px" label="纪律处分人数" required>
                <a-input-number v-model="addDataForm.disciplinaryPunishedPersons.value" :precision="0"
                  :style="{ width: '300px' }" />
              </a-form-item>
            </a-col>

            <a-col :span="8" v-if="addDataForm.bigTypeName.value.indexOf('存量化解类') > -1 ||
              addDataForm.bigTypeName.value.indexOf('其他类') > -1 ||
              addDataForm.bigTypeName.value.indexOf('新增问题类') > -1">
              <a-form-item field="recommendationLetters" label-col-flex="120px" label="发出执纪执法建议（文书）数" required>
                <a-input-number v-model="addDataForm.recommendationLetters.value" :precision="0"
                  :style="{ width: '300px' }" />
              </a-form-item>
            </a-col>
          </a-row>

          <a-row v-if="addDataForm.bigTypeName.value.indexOf('存量化解类') > -1 ||
            addDataForm.bigTypeName.value.indexOf('其他类') > -1 ||
            addDataForm.bigTypeName.value.indexOf('新增问题类') > -1"
            v-for="(item, index) in addDataForm.circularIssuesList.value" :key="item.id">
            <a-col :span="8">
              <a-form-item field="circularNo" label-col-flex="120px" label="印发通报编号" required>
                <a-input v-model="item.no" :style="{ width: '300px' }" />
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item field="circularIssues" label-col-flex="120px" label="通报涉及本单位问题数" required>
                <a-input-number v-model="item.value" :precision="0" :style="{ width: '300px' }" />
              </a-form-item>
            </a-col>
            <a-col :span="3">
              <a-button style="margin-top: 35px;" @click="addCircularItem" size="mini">+</a-button>
              <a-button style="margin-top: 35px;margin-left:5px" @click="removeCircularItem(index)"
                size="mini">-</a-button>
            </a-col>
          </a-row>
          <a-row>
            <!-- //建立制度数 -->
            <a-col :span="8" v-if="addDataForm.bigTypeName.value.indexOf('建章立制类') > -1 ||
              addDataForm.bigTypeName.value.indexOf('试点类') > -1 ||
              addDataForm.bigTypeName.value.indexOf('其他类') > -1 ||
              addDataForm.bigTypeName.value.indexOf('新增问题类') > -1">
              <a-form-item field="establishedSystems" label-col-flex="120px" label="建立制度个数" required>
                <a-input-number v-model="addDataForm.establishedSystems.value" :precision="0"
                  :style="{ width: '300px' }" @change="changeEstablishedSystems" />
                <a-input-number v-model="addDataForm.establishedSystems.value" :precision="0"
                  :style="{ width: '300px' }" @change="changeEstablishedSystems" />
              </a-form-item>
            </a-col>
            <a-col :span="8" v-if="addDataForm.bigTypeName.value.indexOf('建章立制类') > -1 ||
              addDataForm.bigTypeName.value.indexOf('试点类') > -1 ||
              addDataForm.bigTypeName.value.indexOf('其他类') > -1 ||
              addDataForm.bigTypeName.value.indexOf('新增问题类') > -1">
              <a-form-item field="establishedName" label-col-flex="120px" label="建立制度名称" required>
                <div>
                  <a-input v-for="(item, index) in addDataForm.establishedSystems.value" :key="index"
                    placeholder="请填写每个制度对应的名称" v-model="addDataForm.establishedNameList.value[index].name"
                    :style="{ width: '300px', marginTop: '5px' }" />
                </div>
              </a-form-item>
            </a-col>

            <a-col :span="24">
              <a-form-item field="remark" label-col-flex="120px" label="其他情况" required>
                <a-textarea v-model="addDataForm.remark.value" :style="{ width: '652px' }" />
              </a-form-item>
            </a-col>
            <!-- <a-col :span="12">
              <a-form-item field="creator" label-col-flex="100px" label="填报人" required>
                  <a-input v-model="addDataForm.creator.value" readonly :style="{ width: '300px' }" />
              </a-form-item>
            </a-col> -->
          </a-row>
        </a-form>
      </div>
    </a-drawer>




    <a-modal v-model:visible="toLeadVisible" @ok="toLeadOk" width="420px" title="表格导入">
      <a-row>
        <a-upload style="margin: 20px 50px;" action="/" class="uploadDiv" accept=".xls,.xlsx" :auto-upload="false"
          :limit="1" ref="uploadRef" @change="onFileChange">
        </a-upload>
        <p style="margin-left: 70px;">仅允许导入 xls、xlsx 格式文件。
          <a-link @click="jumpDowmTemp">
            <template #icon>
              <icon-edit />
            </template>
            下载模板
          </a-link>
        </p>
      </a-row>
    </a-modal>
  </div>
</template>
<script lang="ts" setup>import { ref, reactive } from 'vue';
import { Modal, Message } from '@arco-design/web-vue';
import '@arco-design/web-vue/dist/arco.css'; // 确保引入了样式文件
import { postRequest, uploadFileRequest } from '@/api/common';
import { baseURL } from '@/api/base';
import dayjs from 'dayjs';

const formModel = {
  department: ref<any>(""),
  bigTypeNameList: ref<any[]>([]),
  prominentProblemList: ref<any[]>([]),
  problemTypeList: ref<any[]>([]),
  isTopTen: ref(""),
  dateRange: ref<any[]>([]),
  dateRange2: ref<any[]>([]),
  pageNum: 1,
  pageSize: 10
};
formModel.department.value = undefined;
const format = (options: any) => {
  const labels = options.map(option => option.label);
  addDataForm.problemType.value = labels[1];
  addDataForm.prominentProblem.value = labels[0];
  return labels[0]
}

const fieldNames = { value: 'value', label: 'label' }
const questionList: any[] = [
  {
    label: "“民生小案”破案", value: "101",
    children: [{ label: "不担当不作为、推诿扯皮问题", value: "1" }]
  },
  {
    label: "命案防范", value: "102",
    children: [{ label: "不担当不作为、推诿扯皮问题", value: "2" }]
  },
  {
    label: "矛盾纠纷实质性化解", value: "103",
    children: [{ label: "不担当不作为、推诿扯皮问题", value: "3" }]
  },
  {
    label: "执行难破解难", value: "104",
    children: [{ label: "不担当不作为、推诿扯皮问题", value: "4" }]
  },
  {
    label: "后进村整顿", value: "105",
    children: [{ label: "不担当不作为、推诿扯皮问题", value: "5" }]
  },
  {
    label: "行政村布局调整“后半篇”文章", value: "106",
    children: [{ label: "不担当不作为、推诿扯皮问题", value: "6" }]
  },
  {
    label: "12345投诉办理不及时", value: "107",
    children: [{ label: "不担当不作为、推诿扯皮问题", value: "7" }]
  },
  {
    label: "不担当不作为集中整治处理中其它突出问题", value: "108",
    children: [{ label: "不担当不作为、推诿扯皮问题", value: "8" }]
  },
  {
    label: "政绩观偏差、搞“面子工程”问题", value: "109",
    children: [{ label: "政绩观偏差、搞“面子工程”问题", value: "9" }]
  },
  {
    label: "执行政策“一刀切”、层层加码问题", value: "110",
    children: [{ label: "执行政策“一刀切”、层层加码问题", value: "10" }]
  },
  {
    label: "文风会风不实、搞文山会海问题", value: "111",
    children: [{ label: "文风会风不实、搞文山会海问题", value: "11" }]
  },
  {
    label: "整治形式主义为基层减负存在差距问题", value: "112",
    children: [{ label: "整治形式主义为基层减负存在差距问题", value: "12" }]
  },
  {
    label: "未成年人保护和预防犯罪", value: "113",
    children: [{ label: "漠视群众、脱离群众、侵害群众利益问题", value: "13" }]
  },
  {
    label: "道路交通安全综合治理", value: "114",
    children: [{ label: "漠视群众、脱离群众、侵害群众利益问题", value: "14" }]
  },
  {
    label: "精神障碍患者服务管理", value: "115",
    children: [{ label: "漠视群众、脱离群众、侵害群众利益问题", value: "15" }]
  },
  {
    label: "电信网络诈骗打击", value: "116",
    children: [{ label: "漠视群众、脱离群众、侵害群众利益问题", value: "16" }]
  },
  {
    label: "禁毒工作", value: "117",
    children: [{ label: "漠视群众、脱离群众、侵害群众利益问题", value: "17" }]
  },
  {
    label: "新就业群体“急难愁盼”", value: "118",
    children: [{ label: "漠视群众、脱离群众、侵害群众利益问题", value: "18" }]
  },
  {
    label: "高额彩礼", value: "119",
    children: [{ label: "漠视群众、脱离群众、侵害群众利益问题", value: "19" }]
  },
  {
    label: "外籍新娘管理服务", value: "120",
    children: [{ label: "漠视群众、脱离群众、侵害群众利益问题", value: "20" }]
  },
  {
    label: "失能失智老人日间照护", value: "121",
    children: [{ label: "漠视群众、脱离群众、侵害群众利益问题", value: "21" }]
  },
  {
    label: "留守妇女就业", value: "122",
    children: [{ label: "漠视群众、脱离群众、侵害群众利益问题", value: "22" }]
  },
  {
    label: "留守儿童假期托管", value: "123",
    children: [{ label: "漠视群众、脱离群众、侵害群众利益问题", value: "23" }]
  },
  {
    label: "慢性病老人心电图“一张网”", value: "124",
    children: [{ label: "漠视群众、脱离群众、侵害群众利益问题", value: "24" }]
  },
  {
    label: "中小学生午休“趴睡”变“躺睡”", value: "125",
    children: [{ label: "漠视群众、脱离群众、侵害群众利益问题", value: "25" }]
  },
  {
    label: "市区老年人娱乐场所建设", value: "126",
    children: [{ label: "漠视群众、脱离群众、侵害群众利益问题", value: "26" }]
  },
  {
    label: "“群腐”集中整治处理中其他突出问题", value: "127",
    children: [{ label: "漠视群众、脱离群众、侵害群众利益问题", value: "27" }]
  },
  {
    label: "违规吃喝问题", value: "128",
    children: [{ label: "违规吃喝问题", value: "28" }]
  },
  {
    label: "违规收送礼品礼金问题", value: "129",
    children: [{ label: "违规收送礼品礼金问题", value: "29" }]
  },
  {
    label: "借调研培训等名义公款旅游问题", value: "130",
    children: [{ label: "借调研培训等名义公款旅游问题", value: "30" }]
  },
  {
    label: "违规建设、奢华装修楼堂馆所问题", value: "131",
    children: [{ label: "违规建设、奢华装修楼堂馆所问题", value: "31" }]
  },
  {
    label: "开展照顾性、无实质内容的一般性出国（境）活动问题", value: "132",
    children: [{ label: "开展照顾性、无实质内容的一般性出国（境）活动问题", value: "32" }]
  },
  {
    label: "酒驾醉驾问题", value: "133",
    children: [{ label: "酒驾醉驾问题", value: "33" }]
  },
  {
    label: "违规打牌和赌博问题", value: "134",
    children: [{ label: "违规打牌和赌博问题", value: "34" }]
  },
  {
    label: "化解疑难信访积案", value: "135",
    children: [{ label: "化解疑难信访积案", value: "35" }]
  },
  {
    label: "中小学“校园餐”等领域侵害群众利益问题", value: "136",
    children: [{ label: "中小学“校园餐”等领域侵害群众利益问题", value: "36" }]
  },
  {
    label: "公共交通服务质量不优的问题", value: "137",
    children: [{ label: "公共交通服务质量不优的问题", value: "37" }]
  },
  {
    label: "物业服务履约不到位、侵害业主公共收益问题", value: "138",
    children: [{ label: "物业服务履约不到位、侵害业主公共收益问题", value: "38" }]
  },
  {
    label: "大气污染治理问题", value: "139",
    children: [{ label: "大气污染治理问题", value: "39" }]
  }
];
// 建章立制类、存量化解类、新增问题类、试点类、其他类
const questionList1: any[] = [
  {
    label: "建章立制类",
    value: "建章立制类"
  },
  {
    label: "存量化解类",
    value: "存量化解类"
  },
  {
    label: "新增问题类",
    value: "新增问题类"
  },
  {
    label: "试点类",
    value: "试点类"
  },
  {
    label: "其他类",
    value: "其他类"
  }
];

const questionList2: any[] = [
  {
    label: "不担当不作为、推诿扯皮问题"
  },
  {
    label: "政绩观偏差、搞“面子工程”问题"
  },
  {
    label: "执行政策“一刀切”、层层加码问题"
  },
  {
    label: "文风会风不实、搞文山会海问题"
  },
  {
    label: "整治形式主义为基层减负存在差距问题"
  },
  {
    label: "漠视群众、脱离群众、侵害群众利益问题"
  },
  {
    label: "违规吃喝问题"
  },
  {
    label: "违规收送礼品礼金问题"
  },
  {
    label: "借调研培训等名义公款旅游问题"
  },
  {
    label: "违规建设、奢华装修楼堂馆所问题"
  },
  {
    label: "开展照顾性、无实质内容的一般性出国（境）活动问题"
  },
  {
    label: "酒驾醉驾问题"
  },
  {
    label: "违规打牌和赌博问题"
  },
  {
    label: "化解疑难信访积案"
  },
  {
    label: "中小学“校园餐”等领域侵害群众利益问题"
  },
  {
    label: "公共交通服务质量不优的问题"
  },
  {
    label: "物业服务履约不到位、侵害业主公共收益问题"
  },
  {
    label: "大气污染治理问题"
  }
];

const departmentList = ref<any[]>([]);

let totalSize = ref(10);

// 
const toLeadVisible = ref(false);
//fileFlag
const upLoadFileFlag = ref(false);
//toLeadForm 上传文件
let toLeadForm: FormData = new FormData();

let sumData = reactive({
  index: '合计',
  problemsFoundCount: 0,
  closedCount: 0 as any,
  inProgressCount: 0,
  disciplinaryCases: 0,
  punishedPersons: 0,
  disciplinaryPunishedPersons: 0,
  circularIssues: 0 as any,
  recommendationLetters: 0,
  establishedSystems: 0
})
const summary = () => {
  return [sumData]
}

const changeInProgressCount = (val: any) => {
  if (val > 0) {
    addDataForm.inProgressCount.value = addDataForm.problemsFoundCount.value - val
  }
}

const changeEditInProgressCount = (val: any) => {
  if (val > 0) {
    editDataForm.inProgressCount.value = editDataForm.problemsFoundCount.value - val
  }
}

const addCircularItem = () => {
  addDataForm.circularIssuesList.value.push(reactive({
    no: '',
    value: ''
  }))
}
const removeCircularItem = (index: number) => {
  addDataForm.circularIssuesList.value.splice(index, 1);
}

/**
 * 
 * @param val 新增行数
 */
const changeEstablishedSystems = (val: any) => {
  addDataForm.establishedNameList.value = [];
  for (let i = 0; i < val; i++) {
    addDataForm.establishedNameList.value.push({
      label: ''
    })
  }
}

const spanMethod = ({ rowIndex, columnIndex }) => {
  if (rowIndex == 0 && columnIndex == 0) {
    return {
      colspan: 2
    }
  }
}

const bodyCellClass = ({ rowIndex, columnIndex }) => {
  return {
    backgroundColor: 'red'
  }
}

const columns: any = reactive([
  {
    title: '序号',
    dataIndex: 'index',
    align: 'center',
    fixed: 'left',
    width: 60,
  },
  {
    title: '清单查摆问题表现',
    dataIndex: 'prominentProblem',
    align: 'center',
    width: 140,
  },
  {
    title: '突出问题类型',
    dataIndex: 'problemType',
    align: 'center',
    width: 140,
  },
  {
    title: '问题类别',
    dataIndex: 'bigTypeName',
    align: 'center',
    width: 100,
  },
  {
    title: '整改措施',
    dataIndex: 'rectificationMeasures',
    align: 'center',
    slotName: 'rectification',
    width: 220,
  },
  {
    title: '整治责任',
    dataIndex: 'department',
    align: 'center',
    width: 240,
    children: [
      {
        title: '责任单位',
        dataIndex: 'department',
        align: 'center',
        ellipsis: true,
        tooltip: true,
        width: 120,
      },
      {
        title: '牵头领导',
        dataIndex: 'responsibleLeader',
        align: 'center',
        ellipsis: true,
        tooltip: true,
        width: 100,
      },
      {
        title: '分管领导',
        dataIndex: 'supervisingLeader',
        align: 'center',
        ellipsis: true,
        tooltip: true,
        width: 100,
      }
    ]
  },
  {
    title: '完成时限',
    dataIndex: 'completionDeadline',
    align: 'center',
    ellipsis: true,
    tooltip: true,
    width: 140,
  },

  {
    title: '进展成效',
    dataIndex: 'label',
    align: 'center',
    width: 1300,
    children: [{
      title: '自查自纠发现问题数',
      dataIndex: 'problemsFoundCount',
      align: 'center',
      width: 120,
      bodyCellStyle: (record) => {
        return {
          backgroundColor: '#dcb35360'
        }
      }
    }, {
      title: '已整治销号',
      dataIndex: 'closedCount',
      align: 'center',
      width: 120,
      bodyCellStyle: (record) => {
        return {
          backgroundColor: '#dcb35360'
        }
      }
    }, {
      title: '整治处理中',
      dataIndex: 'inProgressCount',
      align: 'center',
      width: 120,
      bodyCellStyle: (record) => {
        return {
          backgroundColor: '#dcb35360'
        }
      }
    }, {
      title: '建立制度数',
      dataIndex: 'establishedSystems',
      align: 'center',
      width: 90,
    }, {
      title: '制度名称',
      dataIndex: 'establishedName',
      align: 'center',
      width: 150,
      slotName: 'established'
    },
    {
      title: '查处违纪违法案件数',
      dataIndex: 'disciplinaryCases',
      align: 'center',
      width: 120,
      bodyCellStyle: (record) => {
        return {
          backgroundColor: '#8ccd8c60'
        }
      }
    }, {
      title: '组织处理人数',
      dataIndex: 'punishedPersons',
      align: 'center',
      width: 120,
      bodyCellStyle: (record) => {
        return {
          backgroundColor: '#8ccd8c60'
        }
      }
    }, {
      title: '纪律处分人数',
      dataIndex: 'disciplinaryPunishedPersons',
      align: 'center',
      width: 120,
      bodyCellStyle: (record) => {
        return {
          backgroundColor: '#8ccd8c60'
        }
      }
    }, {
      title: '印发通报编号',
      dataIndex: 'circularNo',
      align: 'center',
      width: 140,
      slotName: 'circular'
    },
    {
      title: '通报涉及本单位问题数',
      dataIndex: 'circularIssues',
      align: 'center',
      width: 100,
      slotName: 'circularnum'
    },
    {
      title: '发出执纪执法建议（文书）数',
      dataIndex: 'recommendationLetters',
      align: 'center',
      width: 140,
    },
    {
      title: '其他情况',
      dataIndex: 'remark',
      align: 'center',
      slotName: 'remark',
      width: 120,
    },
    ]
  },
  {
    title: '是否属于“十大攻坚”',
    dataIndex: 'isTopTen',
    align: 'center',
    width: 100,
  },
  {
    title: '创建日期',
    dataIndex: 'createdTime',
    align: 'center',
    width: 110,
  },
  {
    title: '操作',
    dataIndex: 'action',
    align: 'center',
    width: 80,
    fixed: 'right',
    slotName: 'action'
  },
]);

const leadAddShow = () => {
  toLeadVisible.value = true;
  toLeadForm = new FormData();
  upLoadFileFlag.value = false;
}
const onFileChange = (fileList: any) => {
  console.log(fileList);
  if (fileList != null && fileList.length > 0) {
    upLoadFileFlag.value = true; //by guo 2020-8-4-15:18添加
    toLeadForm = new FormData();
    toLeadForm.append("file", fileList[0].file);
    toLeadForm.append("userName", localStorage.getItem("userName") as any);
  } else {
    upLoadFileFlag.value = false; //by guo 2020-8-4-15:18添加
    toLeadForm = new FormData();
  }
};
const toLeadOk = async () => {
  if (upLoadFileFlag.value) {
    let res = await uploadFileRequest("dsms/jyData/importData", toLeadForm);
    if (res.data.code == 200) {
      fetchData();
      Message.success(res.data.message + " " + res.data.result + "条")
    } else {
      Message.error(res.data.message)
    }
  } else {
    Message.error("请选择文件");
    toLeadVisible.value = true;
  }
};

const editvisible = ref(false);
const editDataForm = {
  id: ref(0),
  bigTypeName: ref(""),
  prominentProblem: ref(""),
  problemType: ref(""),
  bigTypeNameList: ref<any[]>(),
  remark: ref(""),
  supervisingLeader: ref(""),
  rectificationMeasures: ref(""),
  department: ref(""),
  responsibleLeader: ref(""),
  completionDeadline: ref(""),
  problemsFoundCount: ref(0),
  closedCount: ref(0),
  inProgressCount: ref(0),
  disciplinaryCases: ref(0),
  punishedPersons: ref(0),
  disciplinaryPunishedPersons: ref(0),
  recommendationLetters: ref(0),
  circularIssues: ref(0),
  circularNo: ref(""),
  circularIssuesList: ref<any[]>([
    reactive({
      no: '',
      value: ''
    })
  ]),
  establishedSystems: ref(0),
  establishedName: ref(""),
  establishedNameList: ref<any[]>([]),
  isTopTen: ref(0)
}



const addvisible = ref(false);
const addDataForm = {
  prominentProblem: ref(""),
  problemType: ref(""),
  bigTypeName: ref(""),
  bigTypeNameList: ref<any[]>(),
  remark: ref(""),
  supervisingLeader: ref(""),
  rectificationMeasures: ref(""),
  department: ref(""),
  responsibleLeader: ref(""),
  completionDeadline: ref(""),
  problemsFoundCount: ref(0),
  closedCount: ref(0),
  inProgressCount: ref(0),
  disciplinaryCases: ref(0),
  punishedPersons: ref(0),
  disciplinaryPunishedPersons: ref(0),
  recommendationLetters: ref(0),
  circularIssues: ref(0),
  circularNo: ref(""),
  circularIssuesList: ref<any[]>([
    reactive({
      no: '',
      value: ''
    })
  ]),
  establishedSystems: ref(0),
  establishedName: ref(""),
  establishedNameList: ref<any[]>([]),
  isTopTen: ref(0)
}

const department = localStorage.getItem("department");
let role = localStorage.getItem("userRole");
// if(role != 'admin'){
//   formModel.department.value = department as string;
// }

const changeEditCheckGroup = (val: any) => {
  editDataForm.bigTypeName.value = val.join(",");
}
const changeCheckGroup = (val: any) => {
  addDataForm.bigTypeName.value = val.join(",");

}

const preHandAddOk = () => {
  if (addDataForm.bigTypeName.value == null || addDataForm.bigTypeName.value == "") {
    Message.error("请选择问题类别");
    return false;
  }
  if (addDataForm.bigTypeName.value == null || addDataForm.bigTypeName.value == "") {
    Message.error("请选择问题类别");
    return false;
  }
  if (addDataForm.prominentProblem.value == null || addDataForm.prominentProblem.value == "") {
    Message.error("请选择清单查摆问题表现");
    return false;
  }
  if (addDataForm.problemType.value == null || addDataForm.problemType.value == "") {
    Message.error("请选择突出问题类型");
    return false;
  }
  if (addDataForm.rectificationMeasures.value == null || addDataForm.rectificationMeasures.value == "") {
    Message.error("请填写整改措施");
    return false;
  }
  if (addDataForm.completionDeadline.value == null || addDataForm.completionDeadline.value == "") {
    Message.error("请填写完成时限");
    return false;
  }
  if (addDataForm.responsibleLeader.value == null || addDataForm.responsibleLeader.value == "") {
    Message.error("请填写牵头领导");
    return false;
  }
  if (addDataForm.supervisingLeader.value == null || addDataForm.supervisingLeader.value == "") {
    Message.error("请填写分管领导");
    return false;
  }

  Modal.warning({
    title: "是否确认添加",
    titleAlign: "center",
    content: '是否确认添加，此操作确认保存基本信息后，不可修改，是否确认添加？',
    hideCancel: false,
    onOk() {
      handleAddOk();
    }
  })

}

const handleAddOk = async () => {

  //确认保存后，不可修改
  let isTopTen = 0;
  const fruitSet = new Set([
    '违规吃喝问题',
    '违规收送礼品礼金问题',
    '酒驾醉驾问题',
    '违规打牌和赌博问题',
    '不担当不作为、推诿扯皮问题',
    '化解疑难信访积案',
    '中小学“校园餐”等领域侵害群众利益问题',
    '公共交通服务质量不优的问题',
    '物业服务履约不到位、侵害业主公共收益问题',
    '大气污染治理问题'
  ]);
  if (fruitSet.has(addDataForm.prominentProblem.value) || fruitSet.has(addDataForm.problemType.value)) {
    isTopTen = 1;
  }
  console.log(addDataForm.circularIssuesList.value)
  console.log(addDataForm.establishedNameList.value)

  let circularIssuesJson: any[] = [];
  if (addDataForm.circularIssuesList.value.length > 0) {
    addDataForm.circularIssuesList.value.forEach((item: any) => {
      if (item.no != null && item.no != '' && item.no.length > 1) {
        circularIssuesJson.push({
          no: item.no,
          value: item.value
        })
        addDataForm.circularIssues.value = addDataForm.circularIssues.value + item.value;
      }
    });
    addDataForm.circularNo.value = JSON.stringify(circularIssuesJson);
  }

  console.log(addDataForm.circularNo.value);

  let establishedNameJson: any[] = [];
  if (addDataForm.establishedNameList.value.length > 0) {
    addDataForm.establishedNameList.value.forEach((item: any) => {
      if (item.name != null && item.name != '' && item.name.length > 1) {
        establishedNameJson.push({
          name: item.name
        })
      }
    });
    addDataForm.establishedName.value = JSON.stringify(establishedNameJson);
  }


  console.log(addDataForm.establishedName.value);
  // json
  // circularNo
  // establishedName



  let res = await postRequest("dsms/jyData/addData", {
    bigTypeName: addDataForm.bigTypeName.value,
    prominentProblem: addDataForm.prominentProblem.value,
    problemType: addDataForm.problemType.value,
    rectificationMeasures: addDataForm.rectificationMeasures.value,
    department: addDataForm.department.value,
    responsibleLeader: addDataForm.responsibleLeader.value,
    completionDeadline: addDataForm.completionDeadline.value,
    problemsFoundCount: addDataForm.problemsFoundCount.value,
    closedCount: addDataForm.closedCount.value,
    inProgressCount: addDataForm.inProgressCount.value,
    disciplinaryCases: addDataForm.disciplinaryCases.value,
    punishedPersons: addDataForm.punishedPersons.value,
    remark: addDataForm.remark.value,
    supervisingLeader: addDataForm.supervisingLeader.value,
    disciplinaryPunishedPersons: addDataForm.disciplinaryPunishedPersons.value,
    recommendationLetters: addDataForm.recommendationLetters.value,
    circularIssues: addDataForm.circularIssues.value,
    circularNo: addDataForm.circularNo.value,
    establishedSystems: addDataForm.establishedSystems.value,
    establishedName: addDataForm.establishedName.value,
    isTopTen: isTopTen,
  });
  if (res) {
    Message.success("添加成功");
    addvisible.value = false;
    fetchData();
  }
  totalSize.value = Number(res.total);
}

const addDataShowFun = () => {

  addvisible.value = true;

  addDataForm.prominentProblem.value = "";
  addDataForm.problemType.value = "";
  addDataForm.rectificationMeasures.value = "";
  addDataForm.department.value = department as string;
  addDataForm.responsibleLeader.value = "";
  addDataForm.completionDeadline.value = "";
  addDataForm.problemsFoundCount.value = 0;
  addDataForm.closedCount.value = 0;
  addDataForm.inProgressCount.value = 0;
  addDataForm.disciplinaryCases.value = 0;
  addDataForm.punishedPersons.value = 0;
  addDataForm.disciplinaryPunishedPersons.value = 0;
  addDataForm.recommendationLetters.value = 0;
  addDataForm.circularIssues.value = 0;
  addDataForm.circularNo.value = "";
  addDataForm.circularIssuesList.value = [
    reactive({
      no: '',
      value: ''
    })
  ];
  addDataForm.establishedSystems.value = 0;
  addDataForm.establishedName.value = "";
  addDataForm.establishedNameList.value = [{
    name: ''
  }];
  addDataForm.isTopTen.value = 0;

}
const handleEditCancel = () => {
  editvisible.value = false;
}

const handleEditOk = async () => {
  if (editDataForm.bigTypeName.value == null || editDataForm.bigTypeName.value == "") {
    Message.error("请选择问题类别");
    return false;
  }
  if (editDataForm.bigTypeName.value == null || editDataForm.bigTypeName.value == "") {
    Message.error("请选择问题类别");
    return false;
  }
  if (editDataForm.prominentProblem.value == null || editDataForm.prominentProblem.value == "") {
    Message.error("请选择清单查摆问题表现");
    return false;
  }
  if (editDataForm.problemType.value == null || editDataForm.problemType.value == "") {
    Message.error("请选择突出问题类型");
    return false;
  }
  if (editDataForm.rectificationMeasures.value == null || editDataForm.rectificationMeasures.value == "") {
    Message.error("请填写整改措施");
    return false;
  }
  if (editDataForm.completionDeadline.value == null || editDataForm.completionDeadline.value == "") {
    Message.error("请填写完成时限");
    return false;
  }
  if (editDataForm.responsibleLeader.value == null || editDataForm.responsibleLeader.value == "") {
    Message.error("请填写牵头领导");
    return false;
  }
  if (editDataForm.supervisingLeader.value == null || editDataForm.supervisingLeader.value == "") {
    Message.error("请填写分管领导");
    return false;
  }
  let isTopTen = 0;
  const fruitSet = new Set([
    '违规吃喝问题',
    '违规收送礼品礼金问题',
    '酒驾醉驾问题',
    '违规打牌和赌博问题',
    '不担当不作为、推诿扯皮问题',
    '化解疑难信访积案',
    '中小学“校园餐”等领域侵害群众利益问题',
    '公共交通服务质量不优的问题',
    '物业服务履约不到位、侵害业主公共收益问题',
    '大气污染治理问题'
  ]);
  if (fruitSet.has(editDataForm.prominentProblem.value) || fruitSet.has(editDataForm.problemType.value)) {
    isTopTen = 1;
  }

  let circularIssuesJson: any[] = [];
  if (editDataForm.circularIssuesList.value.length > 0) {
    editDataForm.circularIssuesList.value.forEach((item: any) => {
      if (item.no != null && item.no != '') {
        circularIssuesJson.push({
          no: item.no,
          value: item.value
        })
        editDataForm.circularIssues.value = editDataForm.circularIssues.value + item.value;
      }
    });
    editDataForm.circularNo.value = JSON.stringify(circularIssuesJson);
  }


  let establishedNameJson: any[] = [];
  if (editDataForm.establishedNameList.value.length > 0) {
    editDataForm.establishedNameList.value.forEach((item: any) => {
      if (item.name != null && item.name != '') {
        establishedNameJson.push({
          name: item.name
        })
      }
    });
    editDataForm.establishedName.value = JSON.stringify(establishedNameJson);
  }
  let res = await postRequest("dsms/jyData/updateData", {
    id: editDataForm.id.value,
    prominentProblem: editDataForm.prominentProblem.value,
    problemType: editDataForm.problemType.value,
    rectificationMeasures: editDataForm.rectificationMeasures.value,
    department: editDataForm.department.value,
    responsibleLeader: editDataForm.responsibleLeader.value,
    completionDeadline: editDataForm.completionDeadline.value,
    problemsFoundCount: editDataForm.problemsFoundCount.value,
    closedCount: editDataForm.closedCount.value,
    inProgressCount: editDataForm.inProgressCount.value,
    disciplinaryCases: editDataForm.disciplinaryCases.value,
    punishedPersons: editDataForm.punishedPersons.value,
    disciplinaryPunishedPersons: editDataForm.disciplinaryPunishedPersons.value,
    recommendationLetters: editDataForm.recommendationLetters.value,
    circularIssues: editDataForm.circularIssues.value,
    circularNo: editDataForm.circularNo.value,
    establishedSystems: editDataForm.establishedSystems.value,
    establishedName: editDataForm.establishedName.value,
    isTopTen: isTopTen,
  });
  if (res) {
    Message.success("修改成功");
    editvisible.value = false;
    fetchData();
  }
}


const handleCancel = () => {
  addvisible.value = false;
}

const editItem = async (record: any) => {
  editvisible.value = true;
  editDataForm.id.value = record.id;
  editDataForm.bigTypeName.value = record.bigTypeName;
  editDataForm.bigTypeNameList.value = record.bigTypeName.split(",");
  editDataForm.prominentProblem.value = record.prominentProblem;
  editDataForm.problemType.value = record.problemType;
  editDataForm.rectificationMeasures.value = record.rectificationMeasures;
  editDataForm.department.value = record.department;
  editDataForm.responsibleLeader.value = record.responsibleLeader;
  editDataForm.completionDeadline.value = record.completionDeadline;
  editDataForm.closedCount.value = record.closedCount;
  editDataForm.problemsFoundCount.value = record.problemsFoundCount;
  editDataForm.inProgressCount.value = record.inProgressCount;
  editDataForm.disciplinaryCases.value = record.disciplinaryCases;
  editDataForm.punishedPersons.value = record.punishedPersons;
  editDataForm.disciplinaryPunishedPersons.value = record.disciplinaryPunishedPersons;
  editDataForm.recommendationLetters.value = record.recommendationLetters;
  editDataForm.circularIssues.value = record.circularIssues;
  editDataForm.circularNo.value = record.circularNo;
  if (record.circularNo.length > 1 && record.circularNo.indexOf("[") != -1) {
    editDataForm.circularIssuesList.value = JSON.parse(record.circularNo);
  } else {
    editDataForm.circularIssuesList.value = [
      {
        no: record.circularNo,
        value: record.circularIssues
      }
    ]
  }
  if (record.establishedName.length > 1 && record.establishedName.indexOf("[") != -1) {
    editDataForm.establishedNameList.value = JSON.parse(record.establishedName);
  } else {
    editDataForm.establishedNameList.value = [
      {
        name: record.establishedName
      }
    ]
  }
  editDataForm.circularIssuesList.value = JSON.parse(record.circularNo);
  editDataForm.establishedSystems.value = record.establishedSystems;
  editDataForm.establishedName.value = record.establishedName;
  editDataForm.establishedNameList.value = JSON.parse(record.establishedName);
  editDataForm.isTopTen.value = record.isTopTen;

}

const deleteItem = async (record: any) => {
  Modal.warning({
    title: "是否确认删除",
    titleAlign: "center",
    content: '此操作会永久删除该数据,是否确认要删除?',
    hideCancel: false,
    onOk() {
      postRequest("dsms/jyData/deleteData", { id: record.id }).then(res => {
        fetchData();
      })
    }
  })
}

let renderData = ref<any[]>([]);

const jumpDowmTemp = () => {
  //  console.log(departmentName);
  window.location.href = baseURL + 'dsms/jyData/downExcelData?department=' + department;
}


const fetchData = async () => {
  // let startTime = "";
  // let endTime = "";
  // if(formModel.dateRange.value!=null && formModel.dateRange.value.length>1){
  //   startTime = formModel.dateRange.value[0];
  //   endTime = formModel.dateRange.value[1];
  // }
  sumData.problemsFoundCount = 0;
  sumData.closedCount = 0;
  sumData.inProgressCount = 0;
  sumData.disciplinaryCases = 0;
  sumData.punishedPersons = 0;
  sumData.disciplinaryPunishedPersons = 0;
  sumData.recommendationLetters = 0;
  sumData.circularIssues = 0;
  sumData.establishedSystems = 0;
  let res = await postRequest("dsms/jyData/queryProblemManagementPage", {
    prominentProblemList: formModel.prominentProblemList.value,
    problemTypeList: formModel.problemTypeList.value,
    bigTypeNameList: formModel.bigTypeNameList.value,
    department: formModel.department.value,
    pageNum: 1,
    pageSize: 9999
  });
  res.list.forEach((item: any, index: number) => {
    item.index = index + 1;
    sumData.problemsFoundCount = sumData.problemsFoundCount + item.problemsFoundCount;;
    sumData.closedCount = sumData.closedCount + item.closedCount;
    sumData.inProgressCount = sumData.inProgressCount + item.inProgressCount;
    sumData.disciplinaryCases = sumData.disciplinaryCases + item.disciplinaryCases;
    sumData.punishedPersons = sumData.punishedPersons + item.punishedPersons;
    sumData.disciplinaryPunishedPersons = sumData.disciplinaryPunishedPersons + item.disciplinaryPunishedPersons;
    sumData.recommendationLetters = sumData.recommendationLetters + item.recommendationLetters;
    sumData.circularIssues = sumData.circularIssues + item.circularIssues;
    sumData.establishedSystems = sumData.establishedSystems + item.establishedSystems;

    if (item.circularNo.length > 1 && item.circularNo.indexOf("[") != -1) {
      item.circularIssuesList = JSON.parse(item.circularNo);
      item.circularIssuesList = item.circularIssuesList.filter(issue =>
        issue.no != null && String(issue.no).trim().length > 0
      );
      //去掉为空的和长度小于1的
      //&& item.no.length>1){
      // item.circularIssuesList =  item.circularIssuesList.filter(item => item.no && item.no.trim())
      // item.circularIssuesList = item.filter((item:any) => item.no.length>1);

    } else {
      item.circularIssuesList = [
        {
          no: item.circularNo,
          value: item.circularIssues
        }
      ]
    }

    if (item.establishedName.length > 1 && item.establishedName.indexOf("[") != -1) {
      item.establishedNameList = JSON.parse(item.establishedName);
      item.establishedNameList = item.establishedNameList.filter(issue =>
        issue.name != null && String(issue.name).trim().length > 0
      );
      // item.establishedNameList = item.filter((item:any) => item.name.length>1);
    } else {
      item.establishedNameList = [
        {
          name: item.establishedName
        }
      ]
    }

    // try {
    //   item.circularIssuesList = JSON.parse(item.circularNo);
    //   console.log(item.circularIssuesList);
    // } catch (error) {
    //   item.circularIssuesList = [
    //     // {
    //     //   no:"",
    //     //   value:""
    //     // }
    //   ];
    // }
    // try {
    //   item.establishedNameList = JSON.parse(item.establishedName);
    // } catch (error) {
    //   item.establishedNameList = [
    //     // {
    //     //   name:"",
    //     // }
    //   ];
    // }
    item.createdTime = item.createdTime.substring(0, 10);
    item.isTopTen = item.isTopTen == 1 ? "是" : "否";
    item.department = (item.department != null && item.department != 'null') ? item.department : "";
  })
  renderData.value = res.list;
  totalSize.value = Number(res.total);
}
function jumpPage(val: any) {
  formModel.pageNum = val;
  fetchData();
}

const fetchDepartment = async () => {
  // departmentList
  let res = await postRequest("dsms/jyData/getUserList", {
    pageSize: 999
  });
  // 将res 去重 根据department 去重
  res = res.filter((item: any, index: number, self: any) => {
    return self.findIndex((t: any) => t.department === item.department) === index;
  });
  // 去掉部门为县市区的
  const excludedCounties = ['黄州区', '团风县', '红安县', '麻城市', '罗田县', '英山县', '浠水县', '蕲春县', '武穴市', '黄梅县', '龙感湖', '白莲河'];
  res = res.filter((item: any) => !excludedCounties.includes(item.department));
  departmentList.value = res;
};

fetchDepartment();
fetchData();
</script>
<script lang="ts">
export default {
  name: 'dataUpload',
};
</script>
<style scoped lang="less">
::v-deep(.arco-upload-progress) {
  visibility: hidden;
}

.container {
  padding: 0 20px 20px 20px;
}

::v-deep(.arco-form-item) {
  margin-bottom: 10px;
}

.bg-color-yellow {
  color: yellow;
}
</style>